package com.hmdp.utils;

import com.hmdp.vo.UserVO;
//thredLocal中存的就是UserVO了，而不是实体类，从threadLocal中拿出来的就是UserVO了，返回给前端的用户数据就少了，保护了隐私
public class UserHolder {
    private static final ThreadLocal<UserVO> tl = new ThreadLocal<>();

    public static void saveUser(UserVO userVO){
        tl.set(userVO);
    }

    public static UserVO getUser(){
        return tl.get();
    }

    public static void removeUser(){
        tl.remove();
    }
}
